<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

</body>
<script>
    // defineProperty:将对象的数据进行拦截。
    const data = {
        userName:"zhangsan"
    }
    let _userName = data.userName;
    Object.defineProperty(data,"userName",{
        get(){
            console.log("get:在读取数据时！，返回的值即是获取的值");
            return "《"+_userName+"》";
        },
        set(v){
            console.log("set:设置数据时！",v);
            _userName = v;
        }
    })
    data.userName = "lisi";
    console.log(data.userName);// zhangsan;
</script>
</html>